package cn.demo.common.utils;

import com.mybatisflex.core.query.QueryTable;
import org.springframework.lang.Nullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class CollectionUtils extends org.springframework.util.CollectionUtils {

    public static boolean isNotEmpty(@Nullable Collection<?> collection) {
        return !isEmpty(collection);
    }

    public static String join(Object value) {
        return join(value, StringUtils.DELIMITER);
    }

    public static String join(Object value, String delimiter) {
        if (value instanceof Collection) {
            return join(((Collection<?>) value).stream().map(Object::toString).collect(Collectors.toList()), delimiter);
        } else {
            return value.toString();
        }
    }

    public static String join(Collection<String> value) {
        return String.join(StringUtils.DELIMITER, value);
    }

    public static String join(Collection<String> value, String delimiter) {
        return String.join(delimiter, value);
    }
}
